package online.longzipeng.mywebdemo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import online.longzipeng.mywebdemo.enums.BaseEnum;
import online.longzipeng.mywebdemo.enums.CheckStatusEnum;
import online.longzipeng.mywebdemo.enums.OptionTypeEnum;
import online.longzipeng.mywebdemo.enums.UserStatusEnum;
import online.longzipeng.mywebdemo.pojo.vo.OptionVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: lzp
 * @description:
 * @Date: 2022/9/30
 */
@RestController
@RequestMapping("/open")
@Api(tags = "开放接口")
public class OpenController {

	@GetMapping("/get/option/type")
	@ApiOperation("获取到所有的选项类型对应")
	public List<OptionVo<Integer>> getOptionsType() {
		return BaseEnum.getOptions(OptionTypeEnum.class);
	}


	@GetMapping("/get/options/by/type")
	@ApiOperation("通过选项类型获取对应的选项")
	public List<OptionVo<Integer>> getOptionsByType(Integer optionType) {
		BaseEnum baseEnum = BaseEnum.valueOf(OptionTypeEnum.class, optionType);
		if (baseEnum != null) {
			OptionTypeEnum optionTypeEnum = (OptionTypeEnum) baseEnum;
			return BaseEnum.getOptions(optionTypeEnum.getEnumClass());
		}
//		if (optionType == 1) {
//			return BaseEnum.getOptions(CheckStatusEnum.class);
//		}else {
//			return BaseEnum.getOptions(UserStatusEnum.class);
//		}
		return null;
	}

	@GetMapping("/get/check/status/options")
	@ApiOperation("获取审核状态的选项列表")
	public List<OptionVo<Integer>> getCheckStatusOptions(Integer optionType) {
		return BaseEnum.getOptions(CheckStatusEnum.class);
	}

	@GetMapping("/get/user/status/options")
	@ApiOperation("获取用户状态的选项列表")
	public List<OptionVo<Integer>> getUserStatusOptions() {
		return BaseEnum.getOptions(UserStatusEnum.class);
	}

}
